package com.lefevre.cms.bean.topic;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.lefevre.cms.bean.MediaInfo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;

/**
 * 话题
 *
 * @author Lefevre
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("topic")
@Entity
@Table(name = "topic", indexes = {@Index(name = "topic_idx", columnList = "tagId,status"), @Index(name = "topic_3_idx", columnList = "userName,postTime"), @Index(name = "topic_5_idx", columnList = "status,sort,lastReplyTime")})
public class Topic implements Serializable {
    private static final long serialVersionUID = -684257451052921859L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @TableId(type = IdType.INPUT)
    private Long id;

    /**
     * 标题
     **/
    @Column(length = 190)
    private String title;

    /**
     * 标签Id
     **/
    private Long tagId;

    /**
     * 标签名称
     **/
    @Transient
    @TableField(exist = false)
    private String tagName;

    /**
     * 话题内容
     **/
    @Lob
    private String content;

    /**
     * 内容摘要
     **/
    @Lob
    private String summary;

    /**
     * 发表时间
     **/
    @Temporal(TemporalType.TIMESTAMP)
    private Date postTime = new Date();

    /**
     * 最后回复时间
     **/
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastReplyTime;

    /**
     * 最后修改时间
     **/
    @Temporal(TemporalType.TIMESTAMP)
    private Date lastUpdateTime;

    /**
     * IP
     **/
    @Column(length = 45)
    private String ip;

    /**
     * IP归属地
     **/
    @Transient
    @TableField(exist = false)
    private String ipAddress;

    /**
     * 图片 List<ImageInfo>json格式
     **/
    @Lob
    private String image;

    @Transient
    @TableField(exist = false)
    private List<ImageInfo> imageInfoList = new ArrayList<>();

    /**
     * 媒体文件信息集合
     **/
    @Transient
    @TableField(exist = false)
    private List<MediaInfo> mediaInfoList = new ArrayList<>();

    /**
     * 评论总数
     **/
    private Long commentTotal = 0L;

    /**
     * 允许评论
     **/
    private boolean allow = true;

    /**
     * 查看总数
     **/
    private Long viewTotal = 0L;

    /**
     * 用户名称
     **/
    @Column(length = 30)
    private String userName;

    /**
     * 呢称
     **/
    @Transient
    @TableField(exist = false)
    private String nickname;

    /**
     * 头像路径
     **/
    @Transient
    @TableField(exist = false)
    private String avatarPath;
    /**
     * 头像名称
     **/
    @Transient
    @TableField(exist = false)
    private String avatarName;
    /**
     * 备注
     */
    @Transient
    @TableField(exist = false)
    private String remarks;

    /**
     * 用户角色名称集合
     **/
    @Transient
    @TableField(exist = false)
    private List<String> userRoleNameList = new ArrayList<>();

    /**
     * 话题允许查看的角色名称集合(默认角色除外)
     **/
    @Transient
    @TableField(exist = false)
    private List<String> allowRoleViewList = new ArrayList<>();

    /**
     * key:内容含有隐藏标签类型  10.输入密码可见  20.评论话题可见  30.达到等级可见 40.积分购买可见 50.余额购买可见  value:当前用户是否已对隐藏内容解锁
     **/
    @Transient
    @TableField(exist = false)
    private LinkedHashMap<Integer, Boolean> hideTagTypeMap = new LinkedHashMap<>();

    /**
     * 发红包Id
     **/
    @Column(length = 32)
    private String giveRedEnvelopeId;

    /**
     * 是否为员工 true:员工  false:会员
     **/
    private Boolean isStaff = false;

    /**
     * 排序
     **/
    private Integer sort = 0;

    /**
     * 精华
     **/
    private Boolean essence = false;

    /**
     * 状态 10.待审核 20.已发布 110.待审核删除 120.已发布删除
     **/
    private Integer status = 10;

}
